package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "payment_plan", schema = "crm")
public class PaymentPlan {
    private int paymentPlanId;
    private BigDecimal paymentPlanAmount;
    private Date paymentPlanDate;
    private Integer paymentPlanPeriods;
    private Integer paymentPlanStatus;
    private String paymentPlanNote;
    private Integer paymentPlanAppStatus;
    private Customer customerByCustomerId;// 供应商
    private Employee employeeByEmpId;
    private Purchase purchaseByPurchaseId;
    private Employee employeeByAppEmpId;
    private List<Approval> approvalsByPaymentPlanId;
    private List<ApprovalRecord> approvalRecordsByPaymentPlanId;
    private List<PaymentRecords> paymentRecordsByPaymentPlanId;

    @Id
    @Column(name = "payment_plan_id", nullable = false)
    public int getPaymentPlanId() {
        return paymentPlanId;
    }

    public void setPaymentPlanId(int paymentPlanId) {
        this.paymentPlanId = paymentPlanId;
    }


    @Basic
    @Column(name = "payment_plan_amount", nullable = true, precision = 2)
    public BigDecimal getPaymentPlanAmount() {
        return paymentPlanAmount;
    }

    public void setPaymentPlanAmount(BigDecimal paymentPlanAmount) {
        this.paymentPlanAmount = paymentPlanAmount;
    }

    @Basic
    @Column(name = "payment_plan_date", nullable = true)
    public Date getPaymentPlanDate() {
        return paymentPlanDate;
    }

    public void setPaymentPlanDate(Date paymentPlanDate) {
        this.paymentPlanDate = paymentPlanDate;
    }

    @Basic
    @Column(name = "payment_plan_periods", nullable = true)
    public Integer getPaymentPlanPeriods() {
        return paymentPlanPeriods;
    }

    public void setPaymentPlanPeriods(Integer paymentPlanPeriods) {
        this.paymentPlanPeriods = paymentPlanPeriods;
    }

    @Basic
    @Column(name = "payment_plan_status", nullable = true)
    public Integer getPaymentPlanStatus() {
        return paymentPlanStatus;
    }

    public void setPaymentPlanStatus(Integer paymentPlanStatus) {
        this.paymentPlanStatus = paymentPlanStatus;
    }

    @Basic
    @Column(name = "payment_plan_note", nullable = true, length = 255)
    public String getPaymentPlanNote() {
        return paymentPlanNote;
    }

    public void setPaymentPlanNote(String paymentPlanNote) {
        this.paymentPlanNote = paymentPlanNote;
    }

    @Basic
    @Column(name = "payment_plan_app_status", nullable = true, length = 255)
    public Integer getPaymentPlanAppStatus() {
        return paymentPlanAppStatus;
    }

    public void setPaymentPlanAppStatus(Integer paymentPlanAppStatus) {
        this.paymentPlanAppStatus = paymentPlanAppStatus;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PaymentPlan that = (PaymentPlan) o;
        return paymentPlanId == that.paymentPlanId &&
                Objects.equals(paymentPlanAmount, that.paymentPlanAmount) &&
                Objects.equals(paymentPlanDate, that.paymentPlanDate) &&
                Objects.equals(paymentPlanPeriods, that.paymentPlanPeriods) &&
                Objects.equals(paymentPlanStatus, that.paymentPlanStatus) &&
                Objects.equals(paymentPlanNote, that.paymentPlanNote);
    }

    @Override
    public int hashCode() {
        return Objects.hash(paymentPlanId, paymentPlanAmount, paymentPlanDate, paymentPlanPeriods, paymentPlanStatus, paymentPlanNote);
    }

    @OneToMany(mappedBy = "paymentPlanByPaymentPlanId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<Approval> getApprovalsByPaymentPlanId() {
        return approvalsByPaymentPlanId;
    }

    public void setApprovalsByPaymentPlanId(List<Approval> approvalsByPaymentPlanId) {
        this.approvalsByPaymentPlanId = approvalsByPaymentPlanId;
    }

    @OneToMany(mappedBy = "paymentPlanByPaymentPlanId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<ApprovalRecord> getApprovalRecordsByPaymentPlanId() {
        return approvalRecordsByPaymentPlanId;
    }

    public void setApprovalRecordsByPaymentPlanId(List<ApprovalRecord> approvalRecordsByPaymentPlanId) {
        this.approvalRecordsByPaymentPlanId = approvalRecordsByPaymentPlanId;
    }

    @OneToMany(mappedBy = "paymentPlanByPaymentPlanId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<PaymentRecords> getPaymentRecordsByPaymentPlanId() {
        return paymentRecordsByPaymentPlanId;
    }

    public void setPaymentRecordsByPaymentPlanId(List<PaymentRecords> paymentRecordsByPaymentPlanId) {
        this.paymentRecordsByPaymentPlanId = paymentRecordsByPaymentPlanId;
    }

    @ManyToOne
    @JoinColumn(name = "purchase_id", referencedColumnName = "purchase_id")
    public Purchase getPurchaseByPurchaseId() {
        return purchaseByPurchaseId;
    }

    public void setPurchaseByPurchaseId(Purchase purchaseByPurchaseId) {
        this.purchaseByPurchaseId = purchaseByPurchaseId;
    }

    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id")
    public Customer getCustomerByCustomerId() {
        return customerByCustomerId;
    }

    public void setCustomerByCustomerId(Customer customerByCustomerId) {
        this.customerByCustomerId = customerByCustomerId;
    }

    @ManyToOne
    @JoinColumn(name = "emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByEmpId() {
        return employeeByEmpId;
    }

    public void setEmployeeByEmpId(Employee employeeByEmpId) {
        this.employeeByEmpId = employeeByEmpId;
    }

    @ManyToOne
    @JoinColumn(name = "app_emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByAppEmpId() {
        return employeeByAppEmpId;
    }

    public void setEmployeeByAppEmpId(Employee employeeByAppEmpId) {
        this.employeeByAppEmpId = employeeByAppEmpId;
    }

}
